package com.welsy.classroom.command
{
	import com.adobe.cairngorm.commands.Command;
	import mx.rpc.IResponder;
	import com.welsy.classroom.event.GetClassComponentsEvent;
	import com.welsy.classroom.business.GetClassComponentsDelegate;
	import com.welsy.usermgt.vo.ClassVO;
	import com.welsy.util.NamespaceLocator;
	import com.welsy.usermgt.vo.UserVO;
	import com.welsy.classroom.model.ClassModelLocator;
	import com.adobe.cairngorm.control.CairngormEvent;
	import mx.controls.Alert;
	import com.welsy.classroom.business.GetAllEditingClassroomDelegate;
	import com.welsy.classroom.model.ClassModelLocator;
	import com.welsy.classroom.business.RemoveClassesDelegate;
	import com.welsy.classroom.event.RemoveClassesEvent;
	import com.welsy.classroom.model.ClassModelLocator;
	import mx.rpc.events.ResultEvent;
	import com.welsy.classroom.model.ClassModelLocator;
	
	public class RemoveClassesCommand implements Command, IResponder
	{
		
		public function execute(event : CairngormEvent):void {
			var delegate : RemoveClassesDelegate = new RemoveClassesDelegate(this);
			var removeClassesEvent : RemoveClassesEvent = RemoveClassesEvent(event);
			
			delegate.removeClasses(removeClassesEvent.classes);
		}
		
		public function result(event : Object) :void {
			trace(ResultEvent(event).result);
			//parse the server result
			//TODO: if the removal was successful, clear the GUI
			ClassModelLocator.getInstance().classRemovalSucceeded = true;
			
			//Ask for the list update
			ClassModelLocator.getInstance().classes = null;
		}
		
		public function fault( event : Object ):void {
			//TODO: report the error
			Alert.show("GetClassComponentsCommand.fault!");
		}
		
	}
}